package com.itawei.d3_io;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;

public class ByteStreamDemo8 {
    public static void main(String[] args) throws IOException {
        /*
        练习：
            文件拷贝
            把C:\Program Files\Java\src(5.54mb)拷贝到当前模块下。
         */

        //1.创建对象
        FileInputStream fis = new FileInputStream("C:\\Program Files\\Java\\src\\qidong.mp4");
        FileOutputStream fos = new FileOutputStream("day06-file-io\\copy.mp4");
        //2.创建一个数组 1024*1024个字节
        byte[] b = new byte[1024*1024];
        long start = System.currentTimeMillis();
        while((fis.read(b)) != -1){
            fos.write(b,0,b.length);
        }
        //3.释放数据
        fos.close();
        fis.close();
        long end = System.currentTimeMillis();
        System.out.println("拷贝完成，耗时："+(end-start));
    }
}
